@inject DarkModeService DarkModeService;
@inject OrchardCore.Environment.Shell.Descriptor.Models.ShellDescriptor shellDescriptor
@inject IOptions<AdminOptions> AdminOptions;
@{
    var adminSettings = Site.As<AdminSettings>();
    var darkMode = await DarkModeService.IsDarkModeAsync();
}
<!DOCTYPE html>
<html lang="@Orchard.CultureName()" dir="@Orchard.CultureDir()" data-theme="@DarkModeService.CurrentTheme" data-darkmode="@adminSettings.DisplayDarkMode">
<head>
    <title>@RenderTitleSegments(Site.SiteName, "before")</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <link type="image/x-icon" rel="shortcut icon" href="~/TheAdmin/favicon.ico" />

    <!-- Bootstrap CSS -->
    <style media="all" asp-name="admin" asp-src="~/TheAdmin/Styles/TheAdmin.min.css" debug-src="~/TheAdmin/Styles/TheAdmin.css"></style>
    <style asp-src="~/DigitalAdmin/overrides.css" depends-on="admin"></style>
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons|Material+Icons+Outlined|Material+Icons+Two+Tone|Material+Icons+Round|Material+Icons+Sharp" rel="stylesheet">

    <script asp-name="font-awesome" at="Foot" version="5"></script>
    <script asp-name="font-awesome-v4-shims" at="Foot" version="5"></script>
    <script asp-name="js-cookie" at="Foot" version="2"></script>
    <script asp-name="admin" asp-src="~/TheAdmin/Scripts/TheAdmin.min.js" debug-src="~/TheAdmin/Scripts/TheAdmin.js" depends-on="jQuery" at="Foot"></script>
    <resources type="Header" />

    <!-- This script can't wait till the footer -->
    <script asp-src="~/TheAdmin/Scripts/TheAdmin-header.min.js" debug-src="~/TheAdmin/Scripts/TheAdmin-header.js"></script>
    @await RenderSectionAsync("HeadMeta", required: false)
</head>
<body class="preload">
    <div class="ta-wrapper">
        <div class="ta-navbar-top navbar-expand-lg bg-primary">
            <div class="d-flex w-100">
                <a class="ta-navbar-brand" href="@Url.Content("~/" + AdminOptions.Value.AdminUrlPrefix)"><img src=@Url.Content("~/TheAdmin/logo.png") alt="@Site.SiteName" /><span>@Site.SiteName</span></a>
            
                <div class="flex-grow-1">
                    @if (adminSettings.DisplayTitlesInTopbar)
                    {
                        @await RenderSectionAsync("Title", required: false)
                    }
                </div>
                <div class="d-flex align-items-center">
                    @await RenderSectionAsync("NavbarTop", required: false)
                    @if (adminSettings.DisplayDarkMode)
                    {
                        <a id="btn-darkmode" class="ml-3" data-toggle="tooltip" title="@(darkMode ? T["Light mode"] : T["Dark mode"])" role="button">
                            @if (darkMode)
                            {
                                <i class="fas fa-sun"></i>
                            }
                            else
                            {
                                <i class="fas fa-moon"></i>
                            }
                        </a>
                    }
                    <a href="@Url.Content("~/")" class="ml-3" target="_blank" data-toggle="tooltip" title="@T["Visit Site"]" role="button">
                        <i class="fa fa-fw fa-external-link"></i>
                    </a>
                    @await DisplayAsync(await New.UserMenu())
                    @if (shellDescriptor.Features.Any(x => x.Id == "OrchardCore.ContentLocalization.ContentCulturePicker"))
                    {
                      <div class="ml-2">
                        <shape type="ContentCulturePicker"></shape>
                      </div>
                    }
                </div>
            </div>
        </div>

        <div id="ta-left-sidebar" class="d-flex flex-column justify-content-between align-items-stretch">
            @await RenderSectionAsync("Navigation", required: false)
            <div class="footer">
                <button class="leftbar-compactor" type="button" title="@T["Collapse / expand menu"]"></button>
            </div>
        </div>

        <div class="ta-content">
            @await RenderSectionAsync("Header", required: false)
            @await RenderSectionAsync("Messages", required: false)
            @await RenderSectionAsync("Breadcrumbs", required: false)
            @if (!adminSettings.DisplayTitlesInTopbar)
            {
                @await RenderSectionAsync("Title", required: false)
            }
            @await RenderBodyAsync()
        </div>

        @await RenderSectionAsync("Footer", required: false)

    </div>
    <div id="confirmRemoveModalMetadata" data-title="@T["Delete"]" data-message="@T["Are you sure you want to remove this element?"]" data-ok-text="@T["Ok"]" data-cancel-text="@T["Cancel"]" data-ok-class="btn-danger" data-cancel-class="btn-secondary"></div>
    <resources type="Footer" />
</body>
</html>
